/**
 * @ClassName LC896
 * @Author ykx
 * @Date 2024/6/23 16:52
 * @Version 1.0
 */
public class LC896 {
    public static void main(String[] args) {

    }

    public boolean isMonotonic(int[] nums) {
        boolean asc = true, desc = true;
        int length = nums.length;
        for (int i = 0; i < length - 1; i++) {
            if (nums[i] > nums[i + 1]) {
                asc = false;
            }
            if (nums[i] < nums[i + 1]) {
                desc = false;
            }
        }
        return asc || desc;
    }

}
